package cn.com.guage;

/**
 * 
 * @author ASUS String中各种方法使用
 */
public class StringTest {

	public static void main(String[] args) {
		String s = "www.runoob.com";
		// charAt() 方法用于返回指定索引处的字符。索引范围为从 0 到 length() - 1。
		// public char charAt(int index)
		char result1 = s.charAt(6);
		System.out.println(result1);

		String str1 = "Strings";
		String str2 = "Strings";
		String str3 = "Strings123";

		int result2 = str1.compareTo(str2);
		System.out.println(result2);

		result2 = str2.compareTo(str3);
		System.out.println(result2);

		result2 = str3.compareTo(str1);
		System.out.println(result2);
		
		String Str = new String("WWW.RUNOOB.COM");
        System.out.print("返回值 :" );
        //toLowerCase() 方法将字符串转换为小写。
        System.out.println(Str.toLowerCase() );
        
        //contains() 方法用于判断字符串中是否包含指定的字符或字符串。
        //public boolean contains(CharSequence chars)
        String myStr = "Runoob";
        System.out.println(myStr.contains("Run"));
        System.out.println(myStr.contains("run"));
        System.out.println(myStr.contains("o"));
        System.out.println(myStr.contains("s"));
        System.out.println(17 / 8);
        
        String substring = new String("yangdehcao");
        //substring() 方法返回字符串的子字符串。
        //public String substring(int beginIndex)

       // public String substring(int beginIndex, int endIndex)
        System.out.print("返回值 :" );
        System.out.println(substring.substring(4) );
 
        System.out.print("返回值 :" );
        System.out.println(substring.substring(4, 10) );
	}

}
